$(function() {
    
    $('.sf_admin_action_recaudacion > a').on('click', function() {
        $.get($(this).attr('href'), {}, function(data) {
            alert(data);
        }, 'html');
        return false;
    });

    $('.dropdown-menu').each(function(){
        var ancho = $(this).children('.column').length * 250;
        $(this).css('width', ancho);
    });
    
    $('[id*=fecha], [id$=inicio_actividad_docente]').each(function() {
        $(this).datepicker({
            changeMonth: true,
            changeYear: true,
            yearRange: "c-100:c+10"
        });
    });
    
    $('[id*=fecha], [id$=inicio_actividad_docente]').each(function() {
        if($(this).val() != '') {
            var val = $(this).val();
            if(val.match(/\-(\d{2})\-/) != null) {
                var mm = val.match(/\-(\d{2})\-/)[1];
                var dd = val.match(/\-\d+\-(\d{2})/)[1];
                var yyyy = val.match(/(\d{4})\-/)[1];
                $(this).val(dd+'/'+mm+'/'+yyyy);
            }
        } 
    });
    
});